package com.hlc.thread;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * Created by helinchong on 2017/4/1.
 */
public class test {
    public static void main(String[] args) {
        ApplicationContext context=new FileSystemXmlApplicationContext("classpath:spring/applicationContext.xml");
        ExecutorService pool= ((ThreadPoolExecutor)context.getBean("executors"));
        pool.submit(new MyRunnable());
        pool.submit(new MyRunnable());
        pool.shutdown();
    }
}
class MyRunnable implements Runnable{

    public void run() {
        for(int x=0;x<10;x++){
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName());
        }
    }
}